#!/usr/bin/python
# author Yu
# 2023年06月21日
import threading
import time

SUM = 0
def sum_num(mutex):
    # time.sleep(1)
    for i in range(10000000):
        global SUM
        mutex.acquire()
        SUM += 1
        mutex.release()
def sum_num2(mutex):
    # time.sleep(1)
    for i in range(10000000):
        global SUM
        mutex.acquire()
        SUM += 1
        mutex.release()

if __name__ == '__main__':
    mutex= threading.Lock()
    t1 = threading.Thread(target=sum_num,args=(mutex,))
    t2 = threading.Thread(target=sum_num2,args=(mutex,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    print(SUM)